import { request } from "../util/request.js";
export default {
    async login({ adminName, adminPassword }) {
        const data = await request({
            type: "get",
            url: "/api/admins/login",
            data: { adminName, adminPassword },
        });
        this.setToken(data.token);
        return data;
    },
    async reg({ adminName, adminPassword }) {
        return await request({
            type: "post",
            url: "/api/admins/reg",
            data: { adminName, adminPassword },
        })
    },
    setToken: data => { sessionStorage.setItem("uk", data) },
    getToken: () => sessionStorage.getItem("uk"),
    addDate: async ({ _id, date }) => {
        return await request({
            type: "patch",
            url: "/api/admins/",
            data: { _id, date }
        })
    },
    update: async (admin) => {
        return await request({
            type: "put",
            url: `/api/admins/${admin._id}`,
            data: admin
        })
    }
}